﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TamTreSoSinh.DBContext;

namespace TamTreSoSinh
{
    public partial class KnownledgeDetailPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadData();
        }

        private void LoadData()
        {
            DBTamTreEntities dbContext = new DBTamTreEntities();
            int Id;
            bool IsValidId = int.TryParse(Request["Id"], out Id);

            if (!IsValidId)
            {
                return;
            }

            Knownledge knownledge = dbContext.Knownledges.SingleOrDefault(obj => obj.Id == Id);
            if (knownledge == null)
            {
                return;
            }

            lblTitle.Text = knownledge.Title;
            ImgMain.ImageUrl = knownledge.MainImage;
            lblOverview.Text = knownledge.Overview;
            lblContent.Text = knownledge.KnownledgeContent;
            lblDate.Text = knownledge.PublishDate.ToString("d/M/yyyy");
        }
    }
}